package com.cdz.web.controller.bus;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cdz.bus.domain.BusDockingInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cdz.common.annotation.Log;
import com.cdz.common.core.controller.BaseController;
import com.cdz.common.core.domain.AjaxResult;
import com.cdz.common.enums.BusinessType;
import com.cdz.bus.service.IBusDockingInfoService;
import com.cdz.common.utils.poi.ExcelUtil;
import com.cdz.common.core.page.TableDataInfo;

/**
 * 对接信息登录Controller
 * 
 * @author guyi
 * @date 2024-11-17
 */
@RestController
@RequestMapping("/bus/busDockingInfo")
public class BusDockingInfoController extends BaseController
{
    @Autowired
    private IBusDockingInfoService busDockingInfoService;

    /**
     * 查询对接信息登录列表
     */
    @PreAuthorize("@ss.hasPermi('bus:busDockingInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusDockingInfo busDockingInfo)
    {
        startPage();
        List<BusDockingInfo> list = busDockingInfoService.selectBusDockingInfoList(busDockingInfo);
        return getDataTable(list);
    }

    /**
     * 导出对接信息登录列表
     */
    @PreAuthorize("@ss.hasPermi('bus:busDockingInfo:export')")
    @Log(title = "对接信息登录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusDockingInfo busDockingInfo)
    {
        List<BusDockingInfo> list = busDockingInfoService.selectBusDockingInfoList(busDockingInfo);
        ExcelUtil<BusDockingInfo> util = new ExcelUtil<BusDockingInfo>(BusDockingInfo.class);
        util.exportExcel(response, list, "对接信息登录数据");
    }

    /**
     * 获取对接信息登录详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:busDockingInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(busDockingInfoService.selectBusDockingInfoById(id));
    }

    /**
     * 新增对接信息登录
     */
    @PreAuthorize("@ss.hasPermi('bus:busDockingInfo:add')")
    @Log(title = "对接信息登录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusDockingInfo busDockingInfo)
    {
        return toAjax(busDockingInfoService.insertBusDockingInfo(busDockingInfo));
    }


    /**
     * 修改对接信息登录
     */
    @PreAuthorize("@ss.hasPermi('bus:busDockingInfo:edit')")
    @Log(title = "对接信息登录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusDockingInfo busDockingInfo)
    {
        return toAjax(busDockingInfoService.updateBusDockingInfo(busDockingInfo));
    }

    /**
     * 删除对接信息登录
     */
    @PreAuthorize("@ss.hasPermi('bus:busDockingInfo:remove')")
    @Log(title = "对接信息登录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busDockingInfoService.deleteBusDockingInfoByIds(ids));
    }


    /**
     * 刷新token-测试连通性
     */
    @PreAuthorize("@ss.hasPermi('bus:busDockingInfo:add')")
    @Log(title = "刷新token-测试连通性", businessType = BusinessType.INSERT)
    @GetMapping("/refreshToken/{id}")
    public AjaxResult refreshToken(@PathVariable Long id) throws Exception {
        return toAjax(busDockingInfoService.refreshToken(id));
    }

}
